﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _07委托和事件导入
{
    Action<>
    class Program
    {
        //工具方法
        static void ChineseGreeting(string name)
        {
            Console.WriteLine("早上好," + name);
        }
        static void EnglishGreeting(string name)
        {
            Console.WriteLine("Morning," + name);
        }

        static void Main(string[] args)
        {
            /*
            GreetingDelegate delegate1 = new GreetingDelegate(ChineseGreeting);//委托变量
            //delegate1 = ChineseGreeting;//绑定第一个方法
            delegate1 += EnglishGreeting;//再绑定第二个方法
            string key = Console.ReadLine();
            if (key.Equals("d"))
            {
                delegate1 -= EnglishGreeting;//取消绑定方法
            }
           
            GreetPeople("张三", delegate1);
            */
            GreetingManager gm = new GreetingManager();
            GreetingManager.delegate1 += EnglishGreeting;
            GreetingManager.delegate1 += ChineseGreeting;
            gm.GreetPeople("Mr.Zhang");
        }
    }
}
